//
//  UIbarbuttonItem-extension.swift
//  SinaWB
//
//  Created by 财神软件 on 17/2/9.
//  Copyright © 2017年 财神软件. All rights reserved.
//

import Foundation

extension UIBarButtonItem{
    convenience init(title:String ,fontSize:CGFloat=16 ,target:AnyObject? ,action:Selector) {
        let btn = UIButton.init()
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.gray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.setTitle(title, for: .highlighted)
        btn.addTarget(target, action: action, for: .touchUpInside)
//        return UIBarButtonItem.init(customView: btn)
        btn.sizeToFit()
        self.init(customView:btn)
    }
    convenience init(normalimage:UIImage? ,heightimage:UIImage? ,target:AnyObject? ,action:Selector) {
        let btn = UIButton.init()
        btn.contentEdgeInsets=UIEdgeInsetsMake(0, -40, 0, 0)
        btn.imageView?.contentMode = .scaleAspectFit
        btn.setImage(normalimage, for: .normal)
        btn.setImage(heightimage, for: .highlighted)
        btn.addTarget(target, action: action, for: .touchUpInside)
        btn.sizeToFit()
        self.init(customView:btn)
    }
}
